// pages/set/evaluate/evaluate.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
	http:getApp().globalData.map,
	list:[],
	fenshu:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		wx.getStorage({
			key:'uid',
			success: (e) => {
				wx.request({
					url: getApp().globalData.http + 'action=getOrderDetail&oid=' + options.id+'&uid='+e.data.uid+'&L='+options.L,
					success: (en) => {
						console.log(en)
						let a=[]
						en.data.data.Items.forEach(function(item,index){
							a.push({id:item.og_id,fenshu:3,nr:'',imglist:[]})
						})
						this.setData({
							list:a,
							data: en.data.data,
							uid:e.data.uid
						})
					}
				})
			}
		})
  },
  sc(e) {
  	let a = this.data.list
  	if (a[e.currentTarget.dataset.id].imglist.length < 3) {
  		wx.showToast({
  			title: '加载中',
  			icon: 'loading'
  		});
  		let that = this
  		wx.chooseImage({
  			count: 3,
  			sizeType: 'compressed',
  			success: (en) => {
				console.log(en)
  				en.tempFilePaths.forEach(function(item, index) {
  					wx.uploadFile({
  						url: getApp().globalData.http3,
  						filePath: item,
  						name: 'picturePath',
  						success: function(res) {
  							let c = JSON.parse(res.data)
  							a[e.currentTarget.dataset.id].imglist.push({'path':c.data.headImage})
							console.log(a)
  							that.setData({
  								list: a
  							})
  							wx.hideToast();
  						}
  					});
  				})
  			}
  		})
  	}
  },
  dete(e) {
  	let a = this.data.list
  	a[e.currentTarget.dataset.num].imglist.splice(e.currentTarget.dataset.id, 1)
  	this.setData({
  		list: a
  	})
  },
  nr(e){
	  let a=this.data.list
	a[e.currentTarget.dataset.num].nr=e.detail.value
	this.setData({
		list:a
	})
  },
  fenshu(e){
	  let a=this.data.list
	  a[e.currentTarget.dataset.num].fenshu=e.currentTarget.dataset.id
	  this.setData({
		  list:a
	  })
  },
  sure(){
	  let a=this.data.list
	  a=JSON.stringify(a)
	  console.log(a)
	  // if(){}
	  wx.request({
		  url:getApp().globalData.http+'action=addPingLun&userid='+this.data.uid+'&plnr='+a,
		  success: (e) => {
		  	console.log(e)
			wx.navigateBack({
				delta:1
			})
		  }
	  })
  }
})